package com.nbot.server.controller;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.nbot.server.domain.ChklogPointDiAnaDO;
import com.nbot.server.service.ChklogPointDiAnaService;
import com.nbot.server.util.PageUtils;
import com.nbot.server.util.Query;
import com.nbot.server.util.R;

/**
 * VIEW
 * 
 * @author nbot
 * @email nbot@163.com
 * @date 2018-06-16 15:20:31
 */
 
@Controller
@RequestMapping("/server/chklogPointDiAna")
public class ChklogPointDiAnaController {
	@Autowired
	private ChklogPointDiAnaService chklogPointDiAnaService;
	
	@GetMapping()
	@RequiresPermissions("server:chklogPointDiAna:chklogPointDiAna")
	String ChklogPointDiAna(){
	    return "server/chklogPointDiAna/chklogPointDiAna";
	}
	
	@ResponseBody
	@GetMapping("/list")
	@RequiresPermissions("server:chklogPointDiAna:chklogPointDiAna")
	public PageUtils list(@RequestParam Map<String, Object> params) throws ParseException {
		//查询列表数据
        Query query = new Query(params);


		Map<String,Object> mapTemp = new HashMap<String,Object>();
		ViewChklogCountController.CovertMapTime(query, mapTemp);
		List<ChklogPointDiAnaDO> chklogPointDiAnaList = chklogPointDiAnaService.list(mapTemp);
		int total = chklogPointDiAnaService.count(mapTemp);
		PageUtils pageUtils = new PageUtils(chklogPointDiAnaList, total);
		return pageUtils;
	}
	
	@GetMapping("/add")
	@RequiresPermissions("server:chklogPointDiAna:add")
	String add(){
	    return "server/chklogPointDiAna/add";
	}

	@GetMapping("/edit/{checkatid}")
	@RequiresPermissions("server:chklogPointDiAna:edit")
	String edit(@PathVariable("checkatid") Long checkatid,Model model){
		ChklogPointDiAnaDO chklogPointDiAna = chklogPointDiAnaService.get(checkatid);
		model.addAttribute("chklogPointDiAna", chklogPointDiAna);
	    return "server/chklogPointDiAna/edit";
	}
	
	/**
	 * 保存
	 */
	@ResponseBody
	@PostMapping("/save")
	@RequiresPermissions("server:chklogPointDiAna:add")
	public R save( ChklogPointDiAnaDO chklogPointDiAna){
		if(chklogPointDiAnaService.save(chklogPointDiAna)>0){
			return R.ok();
		}
		return R.error();
	}
	/**
	 * 修改
	 */
	@ResponseBody
	@RequestMapping("/update")
	@RequiresPermissions("server:chklogPointDiAna:edit")
	public R update( ChklogPointDiAnaDO chklogPointDiAna){
		chklogPointDiAnaService.update(chklogPointDiAna);
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@PostMapping( "/remove")
	@ResponseBody
	@RequiresPermissions("server:chklogPointDiAna:remove")
	public R remove( Long checkatid){
		if(chklogPointDiAnaService.remove(checkatid)>0){
		return R.ok();
		}
		return R.error();
	}
	
	/**
	 * 删除
	 */
	@PostMapping( "/batchRemove")
	@ResponseBody
	@RequiresPermissions("server:chklogPointDiAna:batchRemove")
	public R remove(@RequestParam("ids[]") Long[] checkatids){
		chklogPointDiAnaService.batchRemove(checkatids);
		return R.ok();
	}


	/**
	 * tag
	 */
	@GetMapping( "/tag")
	@ResponseBody
	public List<ChklogPointDiAnaDO> listTag(){
		return chklogPointDiAnaService.listTag();
	}
	/**
	 * tag
	 */
	@GetMapping( "/chkVal")
	@ResponseBody
	public List<ChklogPointDiAnaDO> listChkVal(){
		return chklogPointDiAnaService.listChkVal();
	}
	/**
	 * tag
	 */
	@GetMapping( "/weiZhi")
	@ResponseBody
	public List<ChklogPointDiAnaDO> listWeiZhi(){
		return chklogPointDiAnaService.listWeiZhi();
	}
	/**
	 * tag
	 */
	@GetMapping( "/zhanHao")
	@ResponseBody
	public List<ChklogPointDiAnaDO> listZhanHao(){
		return chklogPointDiAnaService.listZhanHao();
	}
	/**
	 * tag
	 */
	@GetMapping( "/almClass")
	@ResponseBody
	public List<ChklogPointDiAnaDO> listAlmClass(){
		return chklogPointDiAnaService.listAlmClass();
	}
	/**
	 * tag
	 */
	@GetMapping( "/almLevel")
	@ResponseBody
	public List<ChklogPointDiAnaDO> listAlmLevel(){
		return chklogPointDiAnaService.listAlmLevel();
	}
	
}
